<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">



<title>
	
        Spring.Net IoC容器+Observer模式
        -
        LeonJoe的专栏
        - CSDN博客
</title>

    

    

    

    

    

    

    

    

    <link rel="Shortcut Icon" href="1.ico"><link href="http://feeds.feedsky.com/csdn.net/LeonJoe" title="RSS" type="application/rss+xml" rel="alternate">
<link rel="stylesheet" type="text/css" href="index.css" media="all">
</head>
<body id="defaultuser">
    <div id="csdnblog_allwrap">
        <div id="csdnblog_midwrap">
            



<div id="csdnblog_header">
    <h1>
        <a href="http://blog.csdn.net/LeonJoe">
            LeonJoe的专栏</a></h1>
    <h2>
        </h2>
    <ul id="personalnav">
        <li style="display: none;" id="notice"><span class="newnotice"><a class="red" href="http://hi.csdn.net/space-notice.html" target="_top"><span id="noticeCount"></span>条新通知</a></span></li>
        <li style="display: none;"><a id="a_login" href="http://passport.csdn.net/UserLogin.aspx">
            登录</a></li>
        <li style="display: none;"><a id="a_register" href="http://passport.csdn.net/CSDNUserRegister.aspx" target="_top">注册</a></li>
        <li style=""><a id="a_welcome" href="http://hi.csdn.net/DoItNow2" target="_top">欢迎&nbsp;DoItNow2!</a></li>
        <li style=""><a id="a_exit" href="http://writeblog.csdn.net/Signout.aspx">
            退出</a></li>
        <li style=""><a id="a_myblog" href="http://blog.csdn.net/DoItNow2">我的博客</a></li>
        <li style=""><a id="a_configure" href="http://writeblog.csdn.net/configure.aspx" target="_top">配置</a></li>
        <li style=""><a id="a_postedit" href="http://writeblog.csdn.net/PostEdit.aspx" target="_top">写文章</a></li>
        <li style=""><a id="a_postlist" href="http://writeblog.csdn.net/PostList.aspx" target="_top">文章管理</a></li>
        <li><a id="a_bloghome" href="http://blog.csdn.net/" target="_top">博客首页</a></li>
    </ul>
    <ul id="blogsearchsty">
        <li>
            <input value="" id="inputSearch" class="bolgsearch" type="text"></li>
        <li class="selectsty">
            <select name="Search:ddlSearchScope" id="Search_ddlSearchScope">
                <option value="all">全站</option>
                <option value="LeonJoe">当前博客</option>
            </select>
        </li>
        <li>
            <input id="buttonSearch" value="搜索" class="bolggobtn" type="button"></li>
    </ul>
    <ul id="menu">
        <li><a href="http://hi.csdn.net/LeonJoe" target="_top">空间</a></li>
        <li><a class="on" href="http://blog.csdn.net/LeonJoe">博客</a></li>
        <li><a href="http://hi.csdn.net/%21s/friend/list/LeonJoe" target="_top">好友</a></li>
        <li><a href="http://hi.csdn.net/%21s/album/list/LeonJoe" target="_top">相册</a></li>
        <li><a class="last" href="http://hi.csdn.net/%21s/wall/to/LeonJoe" target="_top">
            留言</a></li>
    </ul>
</div>




            
<div id="csdnblog_sidebar">
	<div class="gutter">
		<div class="aboutauthor">
			<dl>
				<dt style="text-align: left;">用户操作</dt>
				<dd class="middle">
					<a href="http://hi.csdn.net/%21s/wall/to/LeonJoe" target="_top">[留言]</a>&nbsp;
					<a href="http://hi.csdn.net/%21s/msg/to/LeonJoe" target="_top">[发消息]</a>&nbsp;
					<a href="http://hi.csdn.net/%21s/friend/add/LeonJoe" target="_top">[加为好友]</a>&nbsp;
				</dd>
				<dt style="text-align: left;">乔亮<span>ID：<a href="http://hi.csdn.net/LeonJoe" target="_top">LeonJoe</a></span></dt><dd class="middle"><a href="http://hi.csdn.net/LeonJoe" target="_top"><img class="avatar" src="1_leonjoe.jpg" alt="乔亮"></a></dd><dd style="text-align: left;"></dd><dt style="text-align: left;">乔亮的文章</dt><dd style="text-align: left;">原创 6 篇</dd><dd style="text-align: left;">翻译 0 篇</dd><dd style="text-align: left;">转载 1 篇</dd><dd style="text-align: left;">评论 4 篇</dd>
				<span id="SubscriptionList">
					<dt style="text-align: left;">订阅我的博客</dt>
					<dd style="text-align: left;">
						<a href="http://feeds.feedsky.com/csdn.net/LeonJoe">
							<img alt="XML聚合" src="gif" border="0">
						</a>&nbsp;&nbsp;
						<a href="http://feeds.feedsky.com/csdn.net/LeonJoe" target="_top">
							<img alt="FeedSky" src="feedsky.gif" border="0">
						</a>
					</dd>
					<dd style="text-align: left;">
						<a href="http://www.xianguo.com/subscribe.php?url=http://feeds.feedsky.com/csdn.net/LeonJoe" target="_top">
							<img alt="订阅到鲜果" src="rss_xianguo.jpg" border="0">
						</a>
					</dd>
					<dd style="text-align: left;">
						<a href="http://fusion.google.com/add?feedurl=http://feeds.feedsky.com/csdn.net/LeonJoe" target="_top">
							<img alt="订阅到Google" src="rss_google.gif" border="0">
						</a>
					</dd>
					<dd style="text-align: left;">
						<a href="http://www.zhuaxia.com/add_channel.php?url=http://feeds.feedsky.com/csdn.net/LeonJoe" target="_top">
							<img alt="订阅到抓虾" src="rss_zhuaxia.gif" border="0">
						</a>
					</dd>
				</span>
				<dt style="text-align: left;">
					<span class="floatright" style="display: none;"><a class="a_edit" href="http://writeblog.csdn.net/configure.aspx" target="_top">[编辑]</a></span>LeonJoe的公告
				</dt>
				<dd style="text-align: left;"></dd>
				<dt style="text-align: left;"><span class="floatright" style="display: none;"><a class="a_edit" href="http://writeblog.csdn.net/EditCategories.aspx?catID=1" target="_top">[编辑]</a></span>文章分类</dt>
				<dd style="text-align: left;">
					<div class="publiclist_sidebar">
						<ul></ul>
					</div>
				</dd>
				
				
				<dt style="text-align: left;">存档</dt>
				<dd style="text-align: left;">
					<div class="publiclist_sidebar">
						<ul><li><a href="http://blog.csdn.net/LeonJoe/archive/2008/04.aspx">2008年04月(7)</a></li></ul>
					</div>
				</dd>
			</dl>
		</div>
	</div>
</div>

            
<div id="csdnblog_content">
    <div class="gutter">
        <div class="default_contents">
            <div class="user_article">

                

                <h1 class="title_txt">
                    <img src="authorship.gif" alt="原创" border="0" height="16" width="15">&nbsp;
                    Spring.Net IoC容器+Observer模式
                    <cite class="fav_csdnstylebykimi"><a href="http://wz.csdn.net/storeit.aspx?t=" class="fav_csdnstylebykimi" title="收藏到我的网摘中，并分享给我的朋友">收藏</a> </cite>
                    
                </h1>
                <div class="blogstory">

                    

                    

                    <p>Spring.Net IoC容器+Observer模式<br>欣喜地看到使用Spring.Net的人越来越多了，网络上介绍Spring.Net的文章也多了起来，不过看来看去，初级的例子总逃不掉Martin Fowler的那个MovieFinder-MovieList，本人自己写了另一个例子，并加入了用Delegate-Event实现的Observer模式，而Subject与Observer的绑定使用IoC Container和属性注入完成，可供大家参考。<br>Observer模式大家应已熟悉，故此处不多做阐述，首先是自定义的事件参数类型与Delegate定义的EventHandler<br></p>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 95%;">
<div><img alt="" src="none.gif" align="top"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventArgs&nbsp;:&nbsp;EventArgs,&nbsp;IObserverEventArgs<br><img id="_71_665_Open_Image" onclick="this.style.display='none'; document.getElementById('_71_665_Open_Text').style.display='none'; document.getElementById('_71_665_Closed_Image').style.display='inline'; document.getElementById('_71_665_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_71_665_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_71_665_Closed_Text').style.display='none'; document.getElementById('_71_665_Open_Image').style.display='inline'; document.getElementById('_71_665_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_71_665_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_71_665_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;ArrayList&nbsp;arl&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ArrayList();<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;index]<br><img id="_168_536_Open_Image" onclick="this.style.display='none'; document.getElementById('_168_536_Open_Text').style.display='none'; document.getElementById('_168_536_Closed_Image').style.display='inline'; document.getElementById('_168_536_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_168_536_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_168_536_Closed_Text').style.display='none'; document.getElementById('_168_536_Open_Image').style.display='inline'; document.getElementById('_168_536_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_168_536_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_168_536_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);"><br><img id="_198_345_Open_Image" onclick="this.style.display='none'; document.getElementById('_198_345_Open_Text').style.display='none'; document.getElementById('_198_345_Closed_Image').style.display='inline'; document.getElementById('_198_345_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_198_345_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_198_345_Closed_Text').style.display='none'; document.getElementById('_198_345_Open_Image').style.display='inline'; document.getElementById('_198_345_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_198_345_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_198_345_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(index&nbsp;</span><span style="color: rgb(0, 0, 0);">&gt;=</span><span style="color: rgb(0, 0, 0);">&nbsp;arl.Count)<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;arl[index];<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);"><br><img id="_375_526_Open_Image" onclick="this.style.display='none'; document.getElementById('_375_526_Open_Text').style.display='none'; document.getElementById('_375_526_Closed_Image').style.display='inline'; document.getElementById('_375_526_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_375_526_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_375_526_Closed_Text').style.display='none'; document.getElementById('_375_526_Open_Image').style.display='inline'; document.getElementById('_375_526_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_375_526_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_375_526_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(index&nbsp;</span><span style="color: rgb(0, 0, 0);">&gt;=</span><span style="color: rgb(0, 0, 0);">&nbsp;arl.Count)<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arl.Add(value);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arl[index]&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;value;<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;Count<br><img id="_571_659_Open_Image" onclick="this.style.display='none'; document.getElementById('_571_659_Open_Text').style.display='none'; document.getElementById('_571_659_Closed_Image').style.display='inline'; document.getElementById('_571_659_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_571_659_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_571_659_Closed_Text').style.display='none'; document.getElementById('_571_659_Open_Image').style.display='inline'; document.getElementById('_571_659_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_571_659_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_571_659_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);"><br><img id="_601_649_Open_Image" onclick="this.style.display='none'; document.getElementById('_601_649_Open_Text').style.display='none'; document.getElementById('_601_649_Closed_Image').style.display='inline'; document.getElementById('_601_649_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_601_649_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_601_649_Closed_Text').style.display='none'; document.getElementById('_601_649_Open_Image').style.display='inline'; document.getElementById('_601_649_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_601_649_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_601_649_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;arl.Count;<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">delegate</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler(Object&nbsp;source,&nbsp;IObserverEventArgs&nbsp;eargs);&nbsp;<br><img alt="" src="none.gif" align="top"></span></div>
</div>

<p>下面是Subject的实现<br></p>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 95%;">
<div><img alt="" src="none.gif" align="top"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);">&nbsp;ISubject<br><img id="_34_179_Open_Image" onclick="this.style.display='none'; document.getElementById('_34_179_Open_Text').style.display='none'; document.getElementById('_34_179_Closed_Image').style.display='inline'; document.getElementById('_34_179_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_34_179_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_34_179_Closed_Text').style.display='none'; document.getElementById('_34_179_Open_Image').style.display='inline'; document.getElementById('_34_179_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_34_179_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_34_179_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;registerobserver(IObserver&nbsp;ob);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;removeobserver(IObserver&nbsp;ob);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;triggerevent(IObserverEventArgs&nbsp;oea);<br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);">&nbsp;<br><img alt="" src="none.gif" align="top"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;Subject&nbsp;:&nbsp;ISubject<br><img id="_223_962_Open_Image" onclick="this.style.display='none'; document.getElementById('_223_962_Open_Text').style.display='none'; document.getElementById('_223_962_Closed_Image').style.display='inline'; document.getElementById('_223_962_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_223_962_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_223_962_Closed_Text').style.display='none'; document.getElementById('_223_962_Open_Image').style.display='inline'; document.getElementById('_223_962_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_223_962_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_223_962_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">event</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler&nbsp;evhdl;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;IObserver&nbsp;_Observer;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;IObserver&nbsp;Observer<br><img id="_354_553_Open_Image" onclick="this.style.display='none'; document.getElementById('_354_553_Open_Text').style.display='none'; document.getElementById('_354_553_Closed_Image').style.display='inline'; document.getElementById('_354_553_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_354_553_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_354_553_Closed_Text').style.display='none'; document.getElementById('_354_553_Open_Image').style.display='inline'; document.getElementById('_354_553_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_354_553_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_354_553_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);"><br><img id="_384_543_Open_Image" onclick="this.style.display='none'; document.getElementById('_384_543_Open_Text').style.display='none'; document.getElementById('_384_543_Closed_Image').style.display='inline'; document.getElementById('_384_543_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_384_543_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_384_543_Closed_Text').style.display='none'; document.getElementById('_384_543_Open_Image').style.display='inline'; document.getElementById('_384_543_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_384_543_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_384_543_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_Observer&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;value;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evhdl&nbsp;</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler(((IObserver)value).RecieveEvent));<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;registerobserver(IObserver&nbsp;ob)<br><img id="_614_714_Open_Image" onclick="this.style.display='none'; document.getElementById('_614_714_Open_Text').style.display='none'; document.getElementById('_614_714_Closed_Image').style.display='inline'; document.getElementById('_614_714_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_614_714_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_614_714_Closed_Text').style.display='none'; document.getElementById('_614_714_Open_Image').style.display='inline'; document.getElementById('_614_714_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_614_714_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_614_714_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evhdl&nbsp;</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventHandler(ob.RecieveEvent));<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;removeobserver(IObserver&nbsp;ob)<br><img id="_773_845_Open_Image" onclick="this.style.display='none'; document.getElementById('_773_845_Open_Text').style.display='none'; document.getElementById('_773_845_Closed_Image').style.display='inline'; document.getElementById('_773_845_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_773_845_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_773_845_Closed_Text').style.display='none'; document.getElementById('_773_845_Open_Image').style.display='inline'; document.getElementById('_773_845_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_773_845_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_773_845_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;evhdl&nbsp;</span><span style="color: rgb(0, 0, 0);">-=</span><span style="color: rgb(0, 0, 0);">&nbsp;(ObserverEventHandler)(ob.RecieveEvent);<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;triggerevent(IObserverEventArgs&nbsp;oea)<br><img id="_912_956_Open_Image" onclick="this.style.display='none'; document.getElementById('_912_956_Open_Text').style.display='none'; document.getElementById('_912_956_Closed_Image').style.display='inline'; document.getElementById('_912_956_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_912_956_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_912_956_Closed_Text').style.display='none'; document.getElementById('_912_956_Open_Image').style.display='inline'; document.getElementById('_912_956_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_912_956_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_912_956_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.evhdl(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">,oea);<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);">&nbsp;<br><img alt="" src="none.gif" align="top"><br><img alt="" src="none.gif" align="top"></span></div>
</div>

<p>接下来是Observer的实现<br></p>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 95%;">
<div><img alt="" src="none.gif" align="top"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);">&nbsp;IObserver<br><img id="_35_103_Open_Image" onclick="this.style.display='none'; document.getElementById('_35_103_Open_Text').style.display='none'; document.getElementById('_35_103_Closed_Image').style.display='inline'; document.getElementById('_35_103_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_35_103_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_35_103_Closed_Text').style.display='none'; document.getElementById('_35_103_Open_Image').style.display='inline'; document.getElementById('_35_103_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_35_103_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_35_103_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;RecieveEvent(</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;obj,&nbsp;IObserverEventArgs&nbsp;ea);<br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;Observer&nbsp;:&nbsp;IObserver<br><img id="_147_581_Open_Image" onclick="this.style.display='none'; document.getElementById('_147_581_Open_Text').style.display='none'; document.getElementById('_147_581_Closed_Image').style.display='inline'; document.getElementById('_147_581_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_147_581_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_147_581_Closed_Text').style.display='none'; document.getElementById('_147_581_Open_Image').style.display='inline'; document.getElementById('_147_581_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_147_581_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_147_581_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;id;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;id_instance;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;Observer()<br><img id="_247_289_Open_Image" onclick="this.style.display='none'; document.getElementById('_247_289_Open_Text').style.display='none'; document.getElementById('_247_289_Closed_Image').style.display='inline'; document.getElementById('_247_289_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_247_289_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_247_289_Closed_Text').style.display='none'; document.getElementById('_247_289_Open_Image').style.display='inline'; document.getElementById('_247_289_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_247_289_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_247_289_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id_instance&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">id;<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;RecieveEvent(Object&nbsp;obj,&nbsp;IObserverEventArgs&nbsp;oea)<br><img id="_368_575_Open_Image" onclick="this.style.display='none'; document.getElementById('_368_575_Open_Text').style.display='none'; document.getElementById('_368_575_Closed_Image').style.display='inline'; document.getElementById('_368_575_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_368_575_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_368_575_Closed_Text').style.display='none'; document.getElementById('_368_575_Open_Image').style.display='inline'; document.getElementById('_368_575_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_368_575_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_368_575_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Observer{0}&nbsp;is&nbsp;triggered!</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;id_instance);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;i&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;&nbsp;i</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">oea.Count;&nbsp;i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Parameters[{0}]:&nbsp;{1}</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,i,oea[i].ToString());<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);">&nbsp;<br><img alt="" src="none.gif" align="top"><br><img alt="" src="none.gif" align="top"><br><img alt="" src="none.gif" align="top"></span></div>
</div>

<p>好了，综上，我们传统的Observer模式的创建便告一段落，接下来我们用Spring.Net的IoC Container(IApplicationContext)来在运行时创建加载配置在文件中的类，并用属性注入的方式对其进行依赖绑定。<br>首先是配置文件：<br></p>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 95%;">
<div><img alt="" src="none.gif" align="top"><span style="color: rgb(0, 0, 0);">&lt;?</span><span style="color: rgb(0, 0, 0);">xml&nbsp;version</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;encoding</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">utf-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top"></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">configuration</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">configSections</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">sectionGroup&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">spring</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">section&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Spring.Context.Support.ContextHandler,&nbsp;Spring.Core</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">section&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">objects</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Spring.Context.Support.DefaultSectionHandler,&nbsp;Spring.Core</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">sectionGroup</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">configSections</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">spring</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">resource&nbsp;uri</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">config://spring/objects</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">context</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">objects&nbsp;xmlns</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><span><a href="http://www.springframework.net/" class="smarterwiki-linkify">http://www.springframework.net</a></span></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">description</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">An&nbsp;example&nbsp;of&nbsp;Spring&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;Observer</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">description</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">subject</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">RichardObserverPattern.Subject,&nbsp;MandyObserverPattern</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">property&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Observer</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">ref</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">observer1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">observer1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">RichardObserverPattern.Observer,&nbsp;MandyObserverPattern</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">objects</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">spring</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="none.gif" align="top"></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">configuration</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;<br><img alt="" src="none.gif" align="top"></span></div>
</div>

<p>其次是客户端的调用：<br></p>
<div style="border: 0.5pt solid windowtext; padding: 4px 5.4pt; background: rgb(230, 230, 230) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; width: 95%;">
<div><img alt="" src="none.gif" align="top"><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;Program<br><img id="_29_529_Open_Image" onclick="this.style.display='none'; document.getElementById('_29_529_Open_Text').style.display='none'; document.getElementById('_29_529_Closed_Image').style.display='inline'; document.getElementById('_29_529_Closed_Text').style.display='inline';" alt="" src="expandedblockstart.gif" align="top"><img id="_29_529_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_29_529_Closed_Text').style.display='none'; document.getElementById('_29_529_Open_Image').style.display='inline'; document.getElementById('_29_529_Open_Text').style.display='inline';" alt="" src="contractedblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_29_529_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_29_529_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;Main(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">[]&nbsp;args)<br><img id="_79_158_Open_Image" onclick="this.style.display='none'; document.getElementById('_79_158_Open_Text').style.display='none'; document.getElementById('_79_158_Closed_Image').style.display='inline'; document.getElementById('_79_158_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_79_158_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_79_158_Closed_Text').style.display='none'; document.getElementById('_79_158_Open_Image').style.display='inline'; document.getElementById('_79_158_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_79_158_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_79_158_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Program&nbsp;p&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;Program();<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.RunningTrunk();<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;RunningTrunk()<br><img id="_203_523_Open_Image" onclick="this.style.display='none'; document.getElementById('_203_523_Open_Text').style.display='none'; document.getElementById('_203_523_Closed_Image').style.display='inline'; document.getElementById('_203_523_Closed_Text').style.display='inline';" alt="" src="expandedsubblockstart.gif" align="top"><img id="_203_523_Closed_Image" style="display: none;" onclick="this.style.display='none'; document.getElementById('_203_523_Closed_Text').style.display='none'; document.getElementById('_203_523_Open_Image').style.display='inline'; document.getElementById('_203_523_Open_Text').style.display='inline';" alt="" src="contractedsubblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="_203_523_Closed_Text" style="border: 1px solid rgb(128, 128, 128); display: none; background-color: rgb(255, 255, 255);">...</span><span id="_203_523_Open_Text"><span style="color: rgb(0, 0, 0);">{<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IApplicationContext&nbsp;ctx&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;ContextRegistry.GetContext();<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ISubject&nbsp;sb&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;(ISubject)ctx.GetObject(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">subject</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IObserverEventArgs&nbsp;oea&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ObserverEventArgs();<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oea[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;oea[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sb.triggerevent(oea);<br><img alt="" src="inblock.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.ReadLine();<br><img alt="" src="expandedsubblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);"><br><img alt="" src="expandedblockend.gif" align="top">&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: rgb(0, 0, 0);">&nbsp;<br><img alt="" src="none.gif" align="top"></span></div>
</div>

<p>我们在这里实实在在地体会到了Spring.Net给我们带来的方便与快捷，不仅如此，还有良好的可扩展与松耦合。<br>在此需要声明的一点是，此例作为学习用例虽让Subject与Observer进行了较紧密的耦合，但在实际实践中Subject与Observer的关系却应该更松一些，也就是只通过Delegate建立方法间的绑定，而非类级别的。另外作为.Net的功能来讲，Delegate乃是其特有的的优秀之处，所以我建议Spring.Net的作者能够在属性注入和构造器注入之外增加方法注入和委托注入，以支持类之间的轻量级的装订与拆卸。<br>&nbsp;</p>
                    <p class="right articalinfo">
                        发表于 @
                        2008年04月04日　22:09:00&nbsp;| <a id="a_comment" href="#FeedBack" title="评论">评论( <span id="FeedbackCount_2252157">1</span>

                            

                            ) </a>| <span style="display: none;"><a class="a_edit" href="http://writeblog.csdn.net/PostEdit.aspx?entryId=2252157" title="编辑">编辑</a>|</span> <a href="mailto:webmaster@csdn.net?subject=Article%20Report%21%21%21&amp;body=Author:LeonJoe%0D%0AURL:http://blog.csdn.net/ArticleContent.aspx?UserName=LeonJoe&amp;Entryid=2252157">
                                    举报</a>| <cite class="fav_csdnstylebykimi"><a href="http://wz.csdn.net/storeit.aspx?t=" class="fav_csdnstylebykimi" title="收藏到我的网摘中，并分享给我的朋友">收藏</a> </cite>
                    </p>
                    <span id="Post.ascx_ViewPost_PreviousAndNextEntriesDown">
                        <h3 class="pagego">
                            <a href="http://blog.csdn.net/LeonJoe/archive/2008/04/06/2254230.aspx">新一篇:牛人也会犯错误 -- 对Jeffrey Ritcher的C#相等判断的考察</a></h3>
                    </span>
                    <div class="mutualitys">
                        <dl>
                            <dt>相关文章<span><a onclick="LogClickCount(this,215)" target="_top" href="http://blog.csdn.net/">查看最新精华文章 请访问博客首页</a></span></dt>
                        </dl>
                    </div>
                </div>
            </div>
            <a name="FeedBack"></a>

            

            <div class="commentslist" id="commentslist">
            <dl class="question"><dt><a id="788341" style="display: none;" title="permalink: 回复:Spring.Net IoC容器+Observer模式" href="http://blog.csdn.net/LeonJoe/archive/2008/04/04/2252157.aspx#788341"></a><a href="http://hi.csdn.net/netcsharp" target="_top" rel="nofollow">netcsharp</a>&nbsp;发表于2008年4月5日 15:44:38&nbsp;&nbsp;<span style="display: none;">IP:</span><a href="mailto:webmaster@csdn.net?subject=Comment%20Report%21%21%21&amp;body=Author:netcsharp%20URL:http://blog.csdn.net/LeonJoe/archive/2008/04/04/2252157.aspx">举报</a><a href="javascript:Reply(788341,'netcsharp')">回复</a><span style="display: none;" class="delete"><a href="javascript:DeleteFeedback(788341)">删除</a></span></dt><dd class="quesauthor"><img alt="" src="2" height="40px" width="40px"></dd><dd><span>星辰技术社区:<a href="http://www.netcsharp.cn,%E6%88%91%E4%BB%AC%E4%BB%A5%E6%9C%80%E5%BF%AB%E7%9A%84%E9%80%9F%E5%BA%A6%E4%B8%BA%E6%82%A8%E6%8F%90%E4%BE%9B%E6%9C%80%E4%BD%B3%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/" class="smarterwiki-linkify">www.netcsharp.cn,我们以最快的速度为您提供最佳的解决方案</a></span></dd></dl></div>

            

            

            <div class="commentnew">
                <dl>
                    <dt>
                        <ul>
                            <li class="left">发表评论</li>

                            <li><a href="http://blog.csdn.net/blogdevteam/archive/2010/01/13/5184213.aspx">“评论王争夺赛”第3期活动开始啦！ </a></li>

                        </ul>
                    </dt>
                    <dd>
                        <ul>
                            <li class="lefttop">表 情：</li>
                            <li class="right"><a href="#" onclick="return false;">
                                <img title="顶" alt="顶" class="brow" src="e01.gif"></a> <a href="#" onclick="return false;">
                                    <img title="砸" alt="砸" class="brow" src="e02.gif"></a> <a href="#" onclick="return false;">
                                        <img title="棒" alt="棒" class="brow" src="e03.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="大笑" alt="大笑" class="brow" src="e04.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="愤怒" alt="愤怒" class="brow" src="e05.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="大哭" alt="大哭" class="brow" src="e06.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="疑问" alt="疑问" class="brow" src="e07.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="汗" alt="汗" class="brow" src="e08.gif"></a> <a href="#" onclick="return false;">
                                        <img title="呕吐" alt="呕吐" class="brow" src="e09.gif"></a>
                                <a href="#" onclick="return false;">
                                    <img title="送花" alt="送花" class="brow" src="e10.gif"></a>
                            </li>
                        </ul>
                        <ul>
                            <li class="left">评论内容：</li>
                            <li class="right">
                                <textarea id="content" class="textarea"></textarea>
                            </li>
                        </ul>
                        <div>
                            <ul>
                                <li class="left">用 户 名：</li>
                                <li class="right"><span id="loginTips" class="right" style="display: none;"><a href="javascript:void(0);" onclick="OpenLoginDialog(this);return false;" class="red" id="loginBtn">登录</a> <a href="http://passport.csdn.net/CSDNUserRegister.aspx" target="_top" class="red">
                                        注册</a> </span><span class="right" style="">
                                            <input id="anonymous" class="checkbox" type="checkbox">匿名评论 </span><span id="commentUser" class="left">DoItNow2</span></li>
                            </ul>
                        </div>
                        <ul style="display: none;">
                            <li class="left">验 证 码：</li>
                            <li class="right">
                                <input value="" id="code" class="input" type="text">
                                <a href="javascript:ChangeIdentifyingCode()">
                                    <img id="imgValidationCode" alt="验证码" style="vertical-align: middle;" src="antibotimage.ashx"></a>
                                <a href="javascript:ChangeIdentifyingCode()">重新获得验证码</a> </li>
                        </ul>
                        <ul>
                            <li class="left">&nbsp;</li>
                            <li class="right"><a href="#" onclick="return false;">
                                <img id="SubmitFeedback" class="btn" style="vertical-align: middle;" src="comment_btn.gif"></a>
                            </li>
                        </ul>
                    </dd>
                </dl>
            </div>

            <img src="pv.aspx" border="0" height="0" width="0">

        </div>
    </div>
</div>

            
<div id="pubfooter">
    <dl>
        <dt></dt>
        <dd>
            Copyright ©
            LeonJoe</dd>
        <dd>
            Powered by CSDN Blog</dd>
    </dl>
</div>

<img src="visitlog.php" alt="" border="0" height="1" width="1"><iframe id="myframe" name="myframe" border="0" src="index_1.html" scrolling="no" frameborder="no" height="0" width="0"></iframe>






        </div>
    </div>
    <img src="count.aspx" height="0" width="0">
</body>
</html>
